<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title>Demo of main GUI with REST API</title>
        <script type="text/javascript">
        function init() {
        	var xhttp = new XMLHttpRequest();
        	xhttp.open("GET", "/jerseyinkaraf/api/counter", false);
            xhttp.send(null);
            var response = JSON.parse(xhttp.responseText);
            console.log("init response.value: " + JSON.stringify(response));
            document.getElementById('counter').value = response.count;
        }
        window.onload = init;

        function incrementCounter() {
        	var xhttp = new XMLHttpRequest();
        	xhttp.open("POST", "/jerseyinkaraf/api/counter", false);
            xhttp.send(null);
            var response = JSON.parse(xhttp.responseText);
            console.log("response.value: " + JSON.stringify(response));
            document.getElementById('counter').value = response.count;
            return false;
        }
        </script>
    </head>
    <body>
        <h1>Demo of main GUI with REST API</h1>

        <form action="">
            <p>
                <strong>Count:</strong> <input type="text" id="counter" value="0"/><br/>
                <button type="button" onclick="incrementCounter()">Increment</button><br/>
            </p>
        </form>
    </body>
</html>
